package jdbc;

import util.DBUtil;

import java.sql.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class Query {
    public static void main(String[] args) {
        Connection connection = DBUtil.get();
        PreparedStatement ps = null;
        ResultSet rs = null;
        String sql = "select * from s_student where sname like ? ";
        try {
            ps = connection.prepareStatement(sql);
            ps.setString(1, "%文%");
            rs = ps.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getLong("stuno"));
                System.out.println(rs.getString("sname"));
                Date enterdate = rs.getDate("enterdate");
                System.out.println("入学时间："+enterdate);
                System.out.println(">>>>>>>>>>>>>>>>>>>");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close(rs,ps,connection);
        }

    }
}
